#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;

class Solution1 {
public:
    int subarraysDivByK(vector<int>& nums, int k) {
        // (sum-x)%k==0 -> sum%x = sum%k
        unordered_map<int, int> hash;
        int ret = 0, sum = 0;

        hash[0] = 1;
        for (auto& x : nums)
        {
            sum += x;
            int r = (sum % k + k) % k;
            if (hash.count(r))
                ret += hash[r];
            ++hash[r];
        }

        return ret;
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    string str;
    cin >> n >> str;

    unordered_map<string, long long> hash;
    hash["s"] = 0, hash["sh"] = 0, hash["shy"] = 0;
    for (int i = 0; i < n; ++i)
    {
        if (str[i] == 's')
            ++hash["s"];
        if (str[i] == 'h')
            hash["sh"] += hash["s"];
        if (str[i] == 'y')
            hash["shy"] += hash["sh"];

    }
    cout << hash["shy"] << endl;

    return 0;
}

struct ListNode {
    int val;
    struct ListNode *next;
    ListNode(int x) :
            val(x), next(NULL) {
    }
};

class Solution {
public:
    ListNode* FindFirstCommonNode(ListNode* pHead1, ListNode* pHead2)
    {
        unordered_map<ListNode*, int> hash;
        ListNode* cur = pHead1;
        while (cur)
        {
            ++hash[cur];
            cur = cur->next;
        }

        cur = pHead2;
        ListNode* ret = nullptr;
        while (cur)
        {
            if (hash.count(cur))
            {
                ret = cur;
                break;
            }
            cur = cur->next;
        }

        return ret;
    }
};


int main1()
{
    string str, del;
    getline(cin, str);
    getline(cin, del);

    unordered_map<char, int> hash;
    for (auto& c : del)
        ++hash[c];

    string ret;
    for (int i = 0; i < str.size(); ++i)
    {
        if (hash.count(str[i]))
            continue;
        ret += str[i];
    }

    cout << ret << endl;

    return 0;
}